home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / 3DVIS10.ZIP / SOURCE4.C < prev    next >
Text File  |  1996-02-29  |  2KB  |  59 lines

  1. /*** SOURCE4.C - Creates a .3DV file with the definition of a curve
  2.          by Lenimar N. Andrade, ccendm03@brufpb.bitnet
  3.       Dep. of Mathematics - Universidade Federal da Paraíba - Brazil ***/
  4.  
  5. #include <stdio.h>
  6. #include <math.h>
  7. #include <conio.h>
  8.  
  9. unsigned nu = 300;
  10. FILE *arq;
  11.  
  12. /* Parametric equations of the curve */
  13. float f1(float t) { return t/10; }
  14. float f2(float t) { return t/10*sin(t); }
  15. float f3(float t) { return t/10*cos(t); }
  16.  
  17. /* ------------------------------------------------------------------------- */
  18.  
  19. void CalcPoints2(float umin, float umax) {
  20.  
  21.   float u, incrU;
  22.   unsigned i;
  23.  
  24.   incrU = (umax - umin)/nu;
  25.  
  26.   fprintf(arq, "%u\n", (nu + 1));
  27.   for (u = umin; u < umax + incrU/2; u+= incrU)
  28.     fprintf(arq, "%6.3f %6.3f %6.3f\n", f1(u), f2(u), f3(u));
  29.  
  30.   fprintf(arq, "%u\n", nu + 1);
  31.   for (i = 1; i <= nu + 1; i++)
  32.     if (i == 1)
  33.       fprintf(arq, "%u %u\n", i, 0);
  34.     else
  35.       fprintf(arq, "%u %u\n", i, YELLOW);
  36. }
  37.  
  38. /* ------------------------------------------------------------------------- */
  39.  
  40. void PrintMsg(void) {
  41.  
  42.   fprintf(arq, "\n%s", "3D curve f(t) = (t/10, t/10*sin(t), t/10*cos(t))");
  43.   fprintf(arq, "\n%s", "Lenimar Nunes de Andrade, ccendm03@brufpb.bitnet\n");
  44. }
  45.  
  46. /* ------------------------------------------------------------------------- */
  47.  
  48. void main(void) {
  49.  
  50.   if ((arq = fopen("demo4.3dv", "wt")) == NULL) return;
  51.   CalcPoints2(-30, 30);
  52.   PrintMsg();
  53.   fclose(arq);
  54. }
  55.  
  56. /* ------------------------------------------------------------------------- */
  57.  
  58. /*** END OF "SOURCE4.C" ***/
  59.